<?php
namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'username'  =>  'require|length:5,16',
        'password' =>  'require|length:6,20|regex:/^(?=.*\d)(?=.*[a-zA-Z]).{6,20}$/',
        'repassword' => 'require|confirm:password',
        'email' =>  ['require','regex' => '/^\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}$/i'],
        'mobile' =>  ['require','regex' => '/^1[3|4|5|7|8][0-9]\d{4,8}$/i'],
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'username.length' => '用户名长度为5-16位',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度为6-20位',
        'password.regex' => '密码只是包含字母和数字，区分大小写',
        'repassword.require' => '确认密码不能为空',
        'repassword.confirm' => '两次密码不一致',
        'email.require' => 'email不能为空',
        'email.regex' => 'email格式错误',
        'mobile.require' => '手机号码不能为空',
        'mobile.regex' => '手机号码格式错误'
    ];

}